<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ taglib prefix="tags" tagdir="/WEB-INF/tags"
%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<head>
    <title><fmt:message key="category" /></title>
</head>
<body>
<script type="text/javascript">
dojo.addOnLoad(function() {
    dojo.query(".categoryAjaxSearch").forEach(function(element) {
        Spring.addDecoration(new Spring.AjaxEventDecoration({
            elementId: element.id,
            event: "onclick",
            params: { decorator: "none" }
        }));
    })

    dojo.query(".categoryAjaxDelete").forEach(function(element) {
        Spring.addDecoration(new Spring.AjaxEventDecoration({
            elementId: element.id,
            event: "onclick",
            popup: "true",
            params: { decorator: "none" }
        }));
    })
	
    dojo.query(".actionUpdate").forEach(function(element) {
        Spring.addDecoration(new Spring.AjaxEventDecoration({
            elementId: element.id,
            event: "onclick",
            popup: "true",
            params: { decorator: "none" }
        }));
    })

    Spring.addDecoration(new Spring.AjaxEventDecoration({
		elementId: 'createLink',
        event: "onclick",
		popup: "true",
        params: { decorator: "none" }
	}));

});
</script>

<div id="columns">

    <h1><fmt:message key="category" /></h1>
    <div class="buttons">
		<c:url var="createUrl" value="/domain/category/createForm.action">
			<c:param name="parentNodeId" value="${categorySearchForm.parentNodeId}"/>
	   </c:url>
       <a id="createLink" href="${createUrl}"><span><fmt:message key="label.link.create" /></span></a>
    </div>

	<c:url var="searchUrl" value="/domain/category/search.action" />
    <h2><fmt:message key="label.search.byExample" /></h2>
    <form:form action="${searchUrl}" modelAttribute="categorySearchForm">
        <table>
            <tbody>
                <tr>
                    <td><fmt:message key="category_name" /></td>
                    <td>
                        <form:input path="category.name" />
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.name",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : false
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.name" />
                    </td>
                    <td><fmt:message key="category_creationBy" /></td>
                    <td>
                        <form:input path="category.creationBy" />
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.creationBy",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : false
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.creationBy" />
                    </td>
                </tr>
                <tr>
                    <td><fmt:message key="category_lastModifiedOn" /></td>
                    <td>
                        <form:input path="category.lastModifiedOn" />
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.lastModifiedOn",
                                widgetType : "dijit.form.DateTextBox",
                                widgetAttrs : {
                                    required : false
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.lastModifiedOn" />
                    </td>
                    <td><fmt:message key="label.pageSize" /></td>
                    <td>
                        <form:select path="searchParameters.pageSize">
                            <form:option value="1" label="1" />
                            <form:option value="5" label="5" />
                            <form:option value="10" label="10" />
                            <form:option value="25" label="25" />
                        </form:select>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "searchParameters.pageSize",
                                widgetType : "dijit.form.FilteringSelect",
                                widgetAttrs : {
                                    required: "false"
                            }}));
                        </script>
                    </td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4">
                        <div class="buttons">
                            <button id="searchButtonEx" type="submit"><fmt:message key="label.search.submit" /></button>
                            <script type="text/javascript">
								Spring.addDecoration(new Spring.AjaxEventDecoration({
									elementId:'searchButtonEx',
									event:'onclick',
									formId:'categorySearchForm',
									params: { decorator: "none" }
								}));
                            </script>
                        </div>
                    </td>
                </tr>
            </tfoot>
        </table>
    </form:form>

	<div id="categorySearchResultFragment">
        <h1><fmt:message key="category" /></h1>
        <c:url var="searchUrl" value="/domain/category/searchAjax.action"/>
        <table class="listEntities">
            <thead>
                <tr>
                    <th scope="col">
                        <a id="sortLinkcreatedOn" class="categoryAjaxSearch" href="${searchUrl}?${categorySearchForm.createdOnQueryStringForSortableHeader}">
                            <fmt:message key="category_createdOn"/>&nbsp;${categorySearchForm.createdOnSortStatusEntity}
                        </a>
                    </th>
                    <th scope="col">
                        <a id="sortLinkname" class="categoryAjaxSearch" href="${searchUrl}?${categorySearchForm.nameQueryStringForSortableHeader}">
                            <fmt:message key="category_name"/>&nbsp;${categorySearchForm.nameSortStatusEntity}
                        </a>
                    </th>
                    <th scope="col">
                        <a id="sortLinkcreationBy" class="categoryAjaxSearch" href="${searchUrl}?${categorySearchForm.creationByQueryStringForSortableHeader}">
                            <fmt:message key="category_creationBy"/>&nbsp;${categorySearchForm.creationBySortStatusEntity}
                        </a>
                    </th>
                    <th scope="col">
                        <a id="sortLinklastModBy" class="categoryAjaxSearch" href="${searchUrl}?${categorySearchForm.lastModByQueryStringForSortableHeader}">
                            <fmt:message key="category_lastModBy"/>&nbsp;${categorySearchForm.lastModBySortStatusEntity}
                        </a>
                    </th>
                    <th scope="col">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
            <c:forEach items="${categories}" var="category" varStatus="status">
                <tr>
                    <td>
                        <c:out value="${category.createdOn}"/>
                    </td>
                    <td>
                        <c:out value="${category.name}"/>
                    </td>
                    <td>
                        <c:out value="${category.creationBy}"/>
                    </td>
                    <td>
                        <c:out value="${category.lastModBy}"/>
                    </td>
                    <td>
                        <c:url var="updateUrl" value="/domain/category/updateForm.action">
                            <c:param name="category.id" value="${category.id}"/>
                        </c:url>
                        <c:url var="confirmDeleteUrl" value="/domain/category/confirmDelete.action">
                            <c:param name="category.id" value="${category.id}"/>
                        </c:url>
                        <a class="actionUpdate" href="${updateUrl}" id="actionUpdate${status.index}"><fmt:message key="label.link.update"/></a>
                        <a class="actionDelete categoryAjaxDelete" id="confirmDeleteUrl${status.index}" href="${confirmDeleteUrl}"><fmt:message key="label.link.delete"/></a>
                    </td>
                </tr>

            </c:forEach>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="14">
                        <p>
                            <tags:navigation pager="${pagerDisplay}" url="${searchUrl}" form="${categorySearchForm}"/>
                        </p>
                    </td>
                </tr>
            </tfoot>
        </table>
	</div>
</div>
</body>
